package com.test;

public class Refelect {

    public static long timeDiff(long old) {
        return System.currentTimeMillis() - old;
    }

    public static void main(String[] args) {

        int numTrials = 10/*00000*/;// (long) Math.pow(10, 7);
        long millis = System.currentTimeMillis();
        JavaTest[] array = new JavaTest[numTrials];
        for (int i = 0; i < numTrials; i++) {
            array[i] = new JavaTest();
        }
        System.out.println("Normal instaniation took: " + timeDiff(millis) + "ms");

        millis = System.currentTimeMillis();
        for (int i = 0; i < numTrials; i++) {
            try {
                array[i] = (JavaTest) Class.forName("com.test.JavaTest").newInstance();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println("Reflecting instantiation took:" + timeDiff(millis) + "ms");

    }
}

